package com.changzhi.controller;

import com.changzhi.common.annotation.Verify;
import com.changzhi.common.util.Result;
import com.changzhi.common.util.TokenUtil;
import com.changzhi.ldyl.model.dto.MatchDto;
import com.changzhi.service.MatchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:王者争霸赛
 * @author: 小落
 * @date: 2021年02月25日
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("match")
public class MatchController {

	@Autowired
	private MatchService matchService;

	@Verify
	@PostMapping("applyInfo")
	public Result applyInfo(@RequestBody @Validated MatchDto matchDto){
		return Result.success(matchService.getApplyInfo(matchDto));
	}

	@Verify
	@PostMapping("confirm")
	public Result confirm(@RequestBody @Validated MatchDto matchDto){
		return Result.success(matchService.confirm(matchDto));
	}

	@Verify
	@PostMapping("apply")
	public Result apply(@RequestBody @Validated MatchDto matchDto){
		matchService.apply(matchDto);
		return Result.success();
	}

	@Verify
	@PostMapping("matchInfo")
	public Result matchInfo(@RequestBody @Validated MatchDto matchDto){
		return Result.success(matchService.matchInfo(matchDto));
	}

	/**
	 * 发放奖品（后台调用）
	 * @param matchDto
	 * @return
	 */
	@PostMapping("givePrize")
	public Result givePrize(@RequestBody @Validated MatchDto matchDto){
		matchService.givePrize(matchDto);
		return Result.success();
	}
}
